package pl.edu.agh.pros.proxy.logic.dao;

import java.util.Collection;

import pl.edu.agh.pros.proxy.logic.dao.common.AbstractDAO;
import pl.edu.agh.pros.proxy.model.XmppServerConfiguration;

import com.google.appengine.api.datastore.Key;

public class XmppServerConfigurationDAO extends AbstractDAO<XmppServerConfiguration> {

	private static final XmppServerConfigurationDAO instance = new XmppServerConfigurationDAO();

	private XmppServerConfigurationDAO() {
		super(XmppServerConfiguration.class);
	}

	public static XmppServerConfigurationDAO getInstance() {
		return instance;
	}

	public Collection<XmppServerConfiguration> getXmppServers(Key providerKey) {
		return this.getObjects("providerKey==param1", "Object param1", providerKey);
	}

	public void saveNewConfiguration(XmppServerConfiguration configuration, Key providerKey) {
		configuration.setProviderKey(providerKey);
		this.save(configuration);
	}

	public void updateConfiguration(XmppServerConfiguration configuration) {
		this.save(configuration);
	}

}
